1. Field
The following relates to a method and system for generating two or three dimensional computer graphics images and more specifically to a method and system for implementing multisample antialiasing (MSAA) when generating such images.
2. Related Art
Antialiasing is a well-known technique for minimising the appearance of jagged edges which result when objects with curved or diagonal lines are displayed on a computer screen. In computer graphics, objects are represented by a plurality of primitives, which are commonly triangular but may be other shapes. A computer screen is physically comprised of many picture elements known as pixels which are usually rectangular and of a certain size. For example, high resolution displays contain an array of at least 1280×1024 pixels. Each pixel is driven to display a certain colour and the computer system generates a colour value to drive each individual pixel. Colours emanating therefrom form an image. Thus, it will be appreciated that where an object has a curved or diagonal line a pixel may belong to more than one object or primitive from which the objects are composed. In other words, the pixel may be split between two or more primitives, or between one or more primitives and the background, by a line passing through the pixel. However, the pixel can only display a single colour at a time. This means that the pixel must be assigned the colour of only one of the primitives which is inaccurate and results in unwanted visual artefacts such as jagged edges which impair the quality of the images.
Antialiasing is based on the principle that the appearance of such visual artefacts may be reduced if the pixels on the edge of a primitive or object are assigned a colour derived from all the primitives/background to which they belong. The jagged edge still exists but the appearance of the jagged edge to a viewer is not as apparent because colour contributions from both objects are used.
One well known antialiasing technique is MultiSample AntiAliasing (MSAA). Instead of assigning pixel characteristics according to the intersection of the centerpoint of the pixel with an object, multiple points dispersed throughout the pixel are used to sample the pixel/object intersection at those particular locations. A pixel is typically divided into two, four or eight sample areas, as illustrated in FIG. 1a. It is then determined whether each of the sample areas falls within a particular primitive or outside it. This is done, for example, by determining whether the centerpoint of each sample area intersects a primitive/object. Those sample areas whose centerpoints are determined to fall within a primitive, are assigned the colour of that primitive for that pixel. Those samples areas which are determined to be outside the primitive or which intersect a different primitive, retain their previous colour or that of the different primitive. An example where a pixel is on the edge of a primitive, a triangle in this example, is illustrated in FIG. 1b. In this example, the pixel is divided into four sample areas and sample areas 2 and 3 are within the triangle and therefore assigned the colour of the triangle for that pixel. Sample areas 0 and 1 are outside the triangle and therefore retain their previous colour. Before rendering, final pixel values are generated based on an average of the colour values assigned to each pixel's sample areas. Advantageously, this means that edges of objects having curved or diagonal lines appear smoothed when the image is rendered.
However, a downside to multisample antialiasing is that pixel values must be stored in a multisample memory for all of the sample areas of all the pixels in an image. The more sample areas into which each pixel is divided, the better the antialiasing results; the smoother the lines appear, but the larger the multisample memory required to store all the sampled pixel values and, moreover, the greater the memory bandwidth consumed to read and write the pixel sample data therefrom.
For each pixel sample area, a value is written to the multisample memory. This means that there is at least two times and often eight times the amount of data to be written to memory, in comparison to using a single sample per pixel.
Furthermore, in rasterization approaches to 3-D rendering, images are rendered from 3-D scenes that may sequentially process primitives in a stream of primitives, some of which may be occluded by later-arriving primitives. Where the closest primitives (visible surfaces) hide other primitives, and the closest primitives are not transparent, it is only the closest primitives which are rendered and are visible to a viewer. In systems using multisample antialiasing, typically, pixel sample values for each pixel at least partially within a primitive are written to the multisample memory. If and when a primitive closer to the viewer overlaps these pixels, then pixel sample values for each of these pixels are overwritten in the multisample memory. Thus, when using multisample antialiasing to generate images from 3-D scenes, particularly complex 3D scenes, in which a great deal of occlusion may be expected, several pixel sample values for each pixel may need to be written to the multisample memory. This increases the demand on memory bandwidth.